package com.gis3c.online.entry;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.gis3c.spatial.entity.BaseFeature;
import com.sun.org.apache.xpath.internal.operations.Bool;

import java.io.Serializable;
import java.util.Set;

/**
 * Created by hukekuan on 2018/3/23.
 */
public class PollutionSourceStation extends BaseFeature{
    private String stationId;
    private String stationName;
    private String stCode;
    private String stName;
    private String areaCode;
    private Double longitude;
    private Double latitude;
    private Integer adminCode;
    private String adminName;
    private String enterpriseCode;
    private String enterpriseName;
    private Double statusCode;
    private Set<PollItem> pollItems;

    /**
     * 判断站点是否超标
     * @return True，超标；False：正常
     */
    private Double CheckExcessive(){
        return pollItems.stream()
                .filter(pollItem -> pollItem.getLevel() != null
                        && !"".equals(pollItem.getLevel())
                        && !"0".equals(pollItem.getLevel()))
                .map(pollItem -> Double.parseDouble(pollItem.getLevel()))
                .findFirst().orElse(0.0);
    }

    public String getStationId() {
        return stationId;
    }

    public void setStationId(String stationId) {
        this.stationId = stationId;
    }

    public String getStationName() {
        return stationName;
    }

    public void setStationName(String stationName) {
        this.stationName = stationName;
    }

    public String getStCode() {
        return stCode;
    }

    public void setStCode(String stCode) {
        this.stCode = stCode;
    }

    public String getAreaCode() {
        return areaCode;
    }

    public void setAreaCode(String areaCode) {
        this.areaCode = areaCode;
    }

    public Double getLongitude() {
        return longitude;
    }

    public void setLongitude(Double longitude) {
        this.longitude = longitude;
    }

    public Double getLatitude() {
        return latitude;
    }

    public void setLatitude(Double latitude) {
        this.latitude = latitude;
    }

    public Integer getAdminCode() {
        return adminCode;
    }

    public void setAdminCode(Integer adminCode) {
        this.adminCode = adminCode;
    }

    public String getEnterpriseCode() {
        return enterpriseCode;
    }

    public void setEnterpriseCode(String enterpriseCode) {
        this.enterpriseCode = enterpriseCode;
    }

    public Set<PollItem> getPollItems() {
        return pollItems;
    }

    public void setPollItems(Set<PollItem> pollItems) {
        this.pollItems = pollItems;
    }

    public Double getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(Double statusCode) {
        if(statusCode.intValue() == 0 && this.CheckExcessive() != 0){
            this.statusCode = this.CheckExcessive();
        }else {
            this.statusCode = statusCode;
        }

    }

    public String getAdminName() {
        return adminName;
    }

    public void setAdminName(String adminName) {
        this.adminName = adminName;
    }

    public String getEnterpriseName() {
        return enterpriseName;
    }

    public void setEnterpriseName(String enterpriseName) {
        this.enterpriseName = enterpriseName;
    }

    public String getStName() {
        return stName;
    }

    public void setStName(String stName) {
        this.stName = stName;
    }
}
